﻿using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vouchers;
using BanHang;
using MuaHang;
using BanLe;
using KeToanTongHop;
using QuanLyKho;
using QuanLyQuy;
using Lists;

namespace ReportGenerators
{
    public class OpenFormChungTu
    {
        //Mở chứng từ từ các nơi khác 
        public void ShowFormChungTuByLoai(Guid chungTuID, DanhSachChungTu dsChungTu)
        {
            try
            {
                Form showedForm = null;

                //Get chúng từ
                ChungTu ct = dsChungTu.GetByChungTuID(chungTuID);
                LoaiChungTu loaiChungTu = DanhMucLoaiChungTu.Instance.GetByID(ct.LoaiChungTuID);

                switch (loaiChungTu.Ma)
                {
                    case "PhieuChi":
                        showedForm = new FrmEditPhieuChi(ct);
                        break;
                    case "PhieuThu":
                        showedForm = new FrmEditPhieuThu(ct);
                        break;
                    case "GiayBaoNo":
                        showedForm = new FrmEditGiayBaoNo(ct);
                        break;
                    case "GiayBaoCo":
                        showedForm = new FrmEditGiayBaoCo(ct);
                        break;
                    case "PhieuNhapKho":
                        showedForm = new FrmEditPhieuNhapKho(ct);
                        break;
                    case "PhieuXuatKho":
                        showedForm = new FrmEditPhieuXuatKho(ct);
                        break;
                    case "PhieuChuyenKho":
                        showedForm = new FrmEditPhieuChuyenKho(ct);
                        break;
                    case "HoaDonBanLe":
                        showedForm = new FrmEditHoaDonBanLe(ct);
                        break;
                    case "HoaDonBanHang":
                        showedForm = new FrmEditHoaDonBanHang(ct);
                        break;
                    case "HoaDonMuaHang":
                        showedForm = new FrmEditHoaDonMuaHang(ct);
                        break;
                    case "HangMuaTraLai":
                        showedForm = new FrmEditHangMuaTraLai(ct);
                        break;
                    case "HangBanTraLai":
                        showedForm = new FrmEditHangBanTraLai(ct);
                        break;
                    case "PhieuKeToan":
                        showedForm = new FrmEditPhieuKeToan(ct);
                        break;
                    case "PhieuBuTruCongNo":
                        showedForm = new FrmEditPhieuBuTruCongNo(ct);
                        break;
                    case "PhieuKetChuyenTuDong":
                        showedForm = new FrmEditPhieuKetChuyenTuDong(ct);
                        break;
                }

                if (showedForm != null)
                {
                    showedForm.Show();
                }
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }
    }
}
